﻿#pragma once

#include <EGL/egl.h>
#include <GLES2/gl2.h>

#include <stdio.h>
#include "lodepng.h"

class CTexture2D
{
public:
	CTexture2D();
	~CTexture2D();

	bool LoadPng(const char* path,bool bKeepAlpha=false);

	bool LoadShaderSource(const char* vs,const char* fs);

	void Release();

	void Update();
	void Render();

	bool GetAlpha(int x,int y);
private:
	bool LoadVshSource(const char* source);
	bool LoadVshBin(const char* bin);
	bool LoadFshSource(const char* source);
	bool LoadFshBin(const char* bin);

	GLuint m_uiTextrueID;
	GLuint m_ShaderProgram;
	GLuint m_VertexShader;
	GLuint m_FragmentShader;

	unsigned int m_uiImgW;
	unsigned int m_uiImgH;
	unsigned int m_uiImgPotW;
	unsigned int m_uiImgPotH;

	bool m_bKeepAlpha;
	std::vector<bool> m_vAlpha;
	
	enum AttribLocation
	{
		m_vertexLoc,
	};
};
